<?php
/* @var $this Controller */
$session = new CHttpSession;
$session->open();

$http = new CHttpRequest;
Yii::app()->user->returnUrl = $http->getUrl();

$baseUrl = Yii::app()->request->baseUrl;



$extScript = Yii::app()->clientScript;
$extScript->registerCoreScript('jquery');
$extScript->registerCssFile($baseUrl . '/js/jquery-ui-1.11.3.custom/jquery-ui.min.js');
$extScript->registerCssFile($baseUrl . '/js/jquery-ui-1.11.3.custom/jquery-ui.css');
$extScript->registerScriptFile($baseUrl . '/layout/scripts/definemyscript.js');
$extScript->registerScriptFile($baseUrl . '/layout/scripts/mobilescript.js', CClientScript::POS_END);
$extScript->registerScriptFile($baseUrl . '/layout/scripts/jquery.flexslider-min.js', CClientScript::POS_END);
?>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
        <meta name="language" content="en">
        <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">

        <link rel="stylesheet" type="text/css" href="<?php echo Yii::app()->request->baseUrl; ?>/css/form.css">
        <link href="<?php echo Yii::app()->request->baseUrl; ?>/layout/styles/layout.css" rel="stylesheet" type="text/css" media="all">

        <title><?php echo CHtml::encode($this->pageTitle); ?></title>
    </head>
    <body id="top">

        <div class="row100 bgded" style="background-image:url('images/live-demo/background-01.jpg');">
            <div class="wrapper row0">
                <div id="topbar" class="clear">
                    <div class="fl_left">
                        <ul class="nospace inline pushright">
                            <li><i class="fa fa-phone"></i> 088-292-4637</li>
                            <li><a class="faicon-adminemail" href="mailto:<?= Yii::app()->params['adminEmail'] ?>" ><i class="fa fa-envelope-o"></i> <?= Yii::app()->params['adminEmail'] ?></a></li>
                            <li>Line : tongdivinerAdmin</li>
                        </ul>
                    </div>
                    <nav id="languages" class="fl_right">
                        <ul class="lang clear">
                            <li class="faicon-facebook"><a href="https://www.facebook.com/tongdiviner"><i class="fa fa-facebook"></i></a></li>
                            <li class="faicon-facebook">
                                <a href="#"><i class="fa fa-globe"></i></a>
                                <ul>
                                    <?php
                                    $links = LanguagesUtil::generateLinks();
                                    for ($i = 0; $i < count($links); $i++) {
                                        echo '<li>' . $links[$i] . '</li>';
                                    }
                                    ?>
                                </ul>
                            </li>
                        </ul>
                    </nav>
                    <div class="fl_right" style="display: none;">
                        <ul class="faico clear">
                            <li><a class="faicon-facebook" href="https://www.facebook.com/tongdiviner"><i class="fa fa-facebook"></i></a></li>
                        </ul>
                    </div>
                </div>
            </div>

            <div class="wrapper row1">
                <header id="header" class="clear">
                    <div id="logo" class="fl_left">
                        <h1><a href="#"><?= CHtml::link(Yii::app()->name, Yii::app()->homeUrl . "?r=index") ?></a></h1>
                    </div>
                    <nav id="mainav" class="fl_right">
                        <?php
                        $this->widget('zii.widgets.CMenu', array(
                            'items' => array(
                                array('label' => Yii::t('home', 'home'), 'url' => array('/admin'), 'visible' => !Yii::app()->user->isGuest && Yii::app()->user->id == SpecialUser::ADMIN_ID, 'active' => strpos(Yii::app()->request->requestUri, 'r=admin') > 0, ''),
                                array('label' => Yii::t('home', 'home'), 'url' => array('/master'), 'visible' => !Yii::app()->user->isGuest && Yii::app()->user->id == SpecialUser::MASTER_ID, 'active' => strpos(Yii::app()->request->requestUri, 'r=master') > 0),
                                array('label' => Yii::t('home', 'home'), 'url' => array('/index'), 'visible' => Yii::app()->user->id !== SpecialUser::ADMIN_ID && Yii::app()->user->id !== SpecialUser::MASTER_ID, 'active' => strpos(Yii::app()->request->requestUri, 'r=index') > 0),
                                // Admin
                                array('label' => Yii::t('home', 'payment_management'), 'url' => array('/paymentmanagement'), 'visible' => !Yii::app()->user->isGuest && Yii::app()->user->id == SpecialUser::ADMIN_ID, 'active' => strpos(Yii::app()->request->requestUri, 'r=paymentmanagement') > 0,),
                                array('label' => Yii::t('home', 'order_management'), 'url' => array('/ordermanagement'), 'visible' => !Yii::app()->user->isGuest && Yii::app()->user->id == SpecialUser::ADMIN_ID, 'active' => strpos(Yii::app()->request->requestUri, 'r=ordermanagement') > 0, 'linkOptions' => array('class' => 'drop'),
                                    'items' => array(
                                        array('label' => '» ' . Yii::t('foretell', 'update'), 'url' => array('/ordermanagement/edit')),
                                    )),
                                array('label' => Yii::t('home', 'user_management'), 'url' => array('/usermanagement'), 'visible' => !Yii::app()->user->isGuest && Yii::app()->user->id == SpecialUser::ADMIN_ID, 'active' => strpos(Yii::app()->request->requestUri, 'r=usermanagement') > 0),
                                array('label' => Yii::t('home', 'foretell'), 'url' => array('/foretell'), 'visible' => Yii::app()->user->id !== SpecialUser::ADMIN_ID && Yii::app()->user->id !== SpecialUser::MASTER_ID, 'active' => strpos(Yii::app()->request->requestUri, 'r=foretell') > 0, 'linkOptions' => array('class' => 'drop'),
                                    'items' => array(
                                        array('label' => '» ' . Yii::t('foretell', 'update'), 'url' => array('/foretell/edit')),
                                        array('label' => '» ' . Yii::t('foretell', 'old_lists'), 'url' => array('/foretell/finish'))
                                    )),
                                array('label' => Yii::t('home', 'how_to_foretell'), 'url' => array('/howtoforetell'), 'visible' => Yii::app()->user->id !== SpecialUser::ADMIN_ID && Yii::app()->user->id !== SpecialUser::MASTER_ID, 'active' => strpos(Yii::app()->request->requestUri, 'r=howtoforetell') > 0),
                                array('label' => Yii::t('home', 'how_to_pay'), 'url' => array('/howtopay'), 'visible' => Yii::app()->user->id !== SpecialUser::ADMIN_ID && Yii::app()->user->id !== SpecialUser::MASTER_ID, 'active' => strpos(Yii::app()->request->requestUri, 'r=howtopay') > 0),
                                array('label' => Yii::t('home', 'payment'), 'url' => array('/payment'), 'visible' => Yii::app()->user->id !== SpecialUser::ADMIN_ID && Yii::app()->user->id !== SpecialUser::MASTER_ID, 'active' => strpos(Yii::app()->request->requestUri, 'r=payment') > 0),
                                array('label' => Yii::t('home', 'contact_us'), 'url' => array('/contactus'), 'visible' => Yii::app()->user->id !== SpecialUser::ADMIN_ID && Yii::app()->user->id !== SpecialUser::MASTER_ID, 'active' => strpos(Yii::app()->request->requestUri, 'r=contactus') > 0),
                                array('label' => Yii::t('home', 'login'), 'url' => array('/login'), 'visible' => Yii::app()->user->isGuest && Yii::app()->user->id !== SpecialUser::ADMIN_ID && Yii::app()->user->id !== SpecialUser::MASTER_ID, 'active' => strpos(Yii::app()->request->requestUri, 'r=login') > 0),
                                array('label' => Yii::t('home', 'register'), 'url' => array('/register'), 'visible' => Yii::app()->user->isGuest && Yii::app()->user->id !== SpecialUser::ADMIN_ID && Yii::app()->user->id !== SpecialUser::MASTER_ID, 'active' => strpos(Yii::app()->request->requestUri, 'r=register') > 0),
                                //array('label' => Yii::t('home', 'my_wish'), 'url' => array('/mywish'), 'visible' => !Yii::app()->user->isGuest && Yii::app()->user->id !== SpecialUser::ADMIN_ID && Yii::app()->user->id !== SpecialUser::MASTER_ID, 'active' => strpos(Yii::app()->request->requestUri, 'r=mywish') > 0),
                                array('label' => Yii::t('home', 'profile'), 'url' => array('/profile'), 'visible' => !Yii::app()->user->isGuest && Yii::app()->user->id !== SpecialUser::ADMIN_ID && Yii::app()->user->id !== SpecialUser::MASTER_ID, 'active' => strpos(Yii::app()->request->requestUri, 'r=profile') > 0),
                                array('label' => Yii::t('home', 'logout'), 'url' => array('/logout'), 'visible' => !Yii::app()->user->isGuest)
//                        array('label' => 'Login', 'url' => array('/site/login'), 'visible' => Yii::app()->user->isGuest),
//                        array('label' => 'Logout (' . Yii::app()->user->name . ')', 'url' => array('/site/logout'), 'visible' => !Yii::app()->user->isGuest)
                            ),
                        ));
                        ?>
                        </div>
                </header>

                <?php if (Yii::app()->user->isGuest || (Yii::app()->user->id !== SpecialUser::ADMIN_ID && Yii::app()->user->id !== SpecialUser::MASTER_ID)) : ?>

                    <div class="wrapper row1">
                        <section id="pageintro" class="clear">

                            <h2 class="font-x3 uppercase nospace btmspace-30"><? echo Yii::t('home', 'main_page') ?></h2>

                            <ul class="nospace inline pushright">
                                <li><a class="btn" href="<?php echo Yii::app()->getBaseUrl(true) . '/index.php?r=foretell' ?>">เริ่มดูดวง</a></li>
                                <li><a class="btn bg-red" href="<?php echo Yii::app()->getBaseUrl(true) . '/index.php?r=howtoforetell' ?>">วิธีดูดวง</a></li>
                            </ul>
                        </section>
                    </div>

                <?php endif; ?>
            </div><!-- mainmenu -->

            <div class="wrapper row2" style="display: none;">
                <div class="container clear" style="padding: 5px;">
                    <?php if (isset($this->breadcrumbs)): ?>
                        <?php
                        $this->widget('zii.widgets.CBreadcrumbs', array(
                            'homeLink' => CHtml::link(Yii::t('home', 'home'), Yii::app()->homeUrl . "?r=index"),
                            'links' => $this->breadcrumbs,
                        ));
                        ?><!-- breadcrumbs -->
                    <?php endif ?>
                </div>
            </div>

            <?php echo $content; ?>

            <div class="clear"></div>

            <div class="wrapper row4">
                <footer id="footer" class="clear">
                    <div class="one_quarter first">
                        <h6 class="title"><? echo Yii::t('home', 'contact_us') ?></h6>
                        <ul class="nospace">
                            <li class="btmspace-10"><span class="fa fa-phone"></span> 088-292-4637</li>
                            <li><span class="fa fa-envelope-o"></span> <? echo Yii::app()->params['adminEmail'] ?></li>
                            
                        </ul>
                    </div>
                    <div class="one_quarter">
                        <h6 class="title"><? echo Yii::t('home', 'link') ?></h6>
                        <ul class="nospace linklist">
                            <li><a href="<? echo Yii::app()->getBaseUrl(true).'/index.php?r=login'; ?>"><? echo Yii::t('home', 'home'); ?></a></li>
                            <li><a href="<? echo Yii::app()->getBaseUrl(true).'/index.php?r=howtoforetell'; ?>"><? echo Yii::t('home', 'how_to_foretell'); ?></a></li>
                            <li><a href="<? echo Yii::app()->getBaseUrl(true).'/index.php?r=howtopay'; ?>"><? echo Yii::t('home', 'how_to_pay') ?></a></li>
                            <li><a href="<? echo Yii::app()->getBaseUrl(true).'/index.php?r=contactus'; ?>"><? echo Yii::t('home', 'contact_us') ?></a></li>
                            <? if(!Yii::app()->user->isGuest && Yii::app()->user->id !== SpecialUser::ADMIN_ID & Yii::app()->user->id !== SpecialUser::MASTER_ID) { ?>
                                    <li><a href="<? echo Yii::app()->getBaseUrl(true).'/index.php?r=profile'; ?>"><? echo Yii::t('home', 'profile') ?></a></li>
                            <? } ?>
                        </ul>
                    </div>
                </footer>
            </div>
            <div class="wrapper row5">
                <div id="copyright" class="clear">
                    <p class="fl_left">Copyright &copy; <?php echo date('Y'); ?> by <a href="#">tongdiviner.com</a> All Rights Reserved. <?php echo Yii::powered(); ?></p>

                </div>
            </div>
            <a id="backtotop" href="#top"><i class="fa fa-chevron-up"></i></a>
            <!-- footer -->

        </div><!-- page -->

    </body>
</html>
